Skip to content

Your activity

Not opened yet on this device.

1. Trust Region Policy Optimization (TRPO)

TRPO improves a policy monotonically by maximizing a surrogate advantage inside a trust region measured with KL divergence. Use it when policy-gradient updates must stay stable, and as the reference that later methods such as PPO simplify.

Reading time
13 min
Length
2,371 words
Updated
Sep 15, 2026
Total views
--

1. Introductions & Preliminaries โ€‹

What is so-called reinforced learning
The reinforced learning is a computational approaches by emphasizing on the learning by an agent from direct interaction with its environment

(1) Concepts of TRPO โ€‹

1. Concepts of random state functions โ€‹

The trust region policy optimization (TRPO)[1] is a gradient-based method optimization algorithm, the variants of TRPO includes the vine method and the single-path method.

  • single-path method can be applied in the model-free-settings
  • vine method requires the system to be restored to particular states.
  1. Firstly, we define the following Markov decision process[2] :
(1.1.1)(S,A,P,r,ฯ0,ฮณ)

We note except the concepts in original statement, the ฯ0 : Sโ†’R is the distribution of the initial state s0, then ฮณโˆˆ(0,1) is discount factor.

The reinforced learning process is a kind of

2. Random state functions โ€‹

Firstly, we define the following 3 random state functions for optimization :

Random state functions

  1. Definition of state-action-value function Qฯ€, defined as the average reward on all available current state and action :
(state-action-value-function)Qฯ€(st,at)=Est+1,at+1,โ€ฆ[โˆ‘l=0โˆžฮณlr(st+l)]

Qฯ€ fixes both the state stโ€‹ and the action at, representing the result when take specific action at. And l is the foresight. This describes the recent reward when we take action at at time t.

  1. The no-policy value function Vฯ€ , we note here the input action of this step at is not defined, so :
(value-function)Vฯ€(st)=Eat,st+1,โ€ฆ[โˆ‘l=0โˆžฮณlr(st+l)]

In this function, the action at is not given, drawn from the policy atโˆผฯ€(โ‹…|st)

  1. The advantage function Aฯ€ is :
(advantage-function)Aฯ€(s,a)=Qฯ€(s,a)โˆ’Vฯ€(s)

where the atโˆผฯ€(at|st) is current-step action, and st+1โˆผP(st+1|st,at) is the next state, and this is affected by the current state st and action at, for every tโ‰ฅ0

We note in above theorem, the Aฯ€ gives the advantage of the specific action on specific state

Also note the definition of the above random-state function in [3] is different, which is :

(1.1.2)Vฯ€(s)โ‰ก(1โˆ’ฮณ)E[โˆ‘l=0โˆžฮณlr(st+l)]

state-action value :

(1.1.3)Qฯ€(s,a)โ‰ก(1โˆ’ฮณ)R(s,a)+ฮณE[Vฯ€(sโ€ฒ)]

The difference is that the (1.1.2~3) is normalized by following factor :

(1.1.4)โˆ‘t=0โˆžฮณl=11โˆ’ฮณ

3. Average Notations under specific policy โ€‹

For a policy with

(1.1.5)Eฯ„โˆผฯ€~[X]=โˆ‘ฯ„Pฯ€~(ฯ„)[X]

where Pฯ€~ is the model decision under specific state and actions, defined by (2.1.2)[2:1]. Since the action is defined on the current state of policy, This can be further expand as (we note s is kept ):

(1.1.6)Eฯ„โˆผฯ€~[X]=1Nโˆ‘i=1NPฯ€~(ฯ„)X(ฯ„)

In the second term in equation , the s is the same

We note we also use following notation :

(1.1.7)Esโˆผdฯ€~,aโˆผฯ€~(โ‹…|s)

(2) Expected discounted reward โ€‹

Here the ฯ€ is a policy that determines the result state. denoted by ฯ€:Sร—Aโ†’[0,1], the ฮท(ฯ€) denotes the expected discounted reward, as given in (2.4.1)[2:2], (2.3.3)[2:3]. which can be rewritten as The sum of the as-far reward:

(1.2.1)ฮท(ฯ€)=Es0,a0,โ€ฆ[โˆ‘t=0โˆžฮณtr(st)]

The initial state is given by:

(1.2.2)s0โˆผฯ0(s0),ย atโˆผฯ€(at|st),ย st+1โˆผP(st+1|st,at)

(3) Policy Relation Theorem โ€‹

Then, the expected return of another policy ฯ€~ in the terms of advantage over ฯ€ can be given as follows, compare to (1.2.1), we should state following lemma :

Policy relation

(policy-relation)ฮท(ฯ€~)=ฮท(ฯ€)+Eฯ„โˆผฯ€~[โˆ‘t=0โˆžฮณtAฯ€(st,at)]

Such expectation is taken over the trajectory ฯ„:=(s0,a0,s1,a1,โ€ฆ)

To derive Lemma. region-policy-relation,.We know from (3.1.1)[2:4] that, for a fixed policy ฯ€, we have :

(1.3.1)Vฯ€(s)=Eaโˆผฯ€(โ‹…|s)[r(s,a)+ฮณVฯ€(s)]

Then Q is, since a is already determined, we have :

(1.3.2)Qฯ€(s,a)=Eฯ€[r(s)+ฮณVฯ€(s)]

We also note here that the optimal policy gives :

(1.3.3)Vโˆ—(s)=maxaQโˆ—(s,a)

Substituting (1.3.2) into (advantage-function), we use the Q as the real value function :

(1.3.4)Aฯ€(s,a)=Eฯ€[r(s)+ฮณVฯ€(sโ€ฒ)โˆ’Vฯ€(s)]

For a specific time t, the E automatically disappear, then :

(1.3.5)Aฯ€(st,at)=r(st)+ฮณVฯ€(st+1)โˆ’Vฯ€(st)

Then, we prove from (policy-relation), here :

(1.3.6)Eฯ„โˆผฯ€~[โˆ‘t=0โˆžฮณtAฯ€]=Eฯ„โˆผฯ€~[โˆ‘t=0โˆž(ฮณt+1Vฯ€(st+1)โˆ’ฮณtVฯ€(st)+ฮณtr(st))]=Erโˆผฯ€~[โˆ‘t=0โˆžฮณtr(st)โˆ’Vฯ€(s0)]

So using (1.2.1), we have :

(1.3.7)Eฯ„โˆผฯ€~[โˆ‘t=0โˆžฮณtAฯ€]=ฮท(ฯ€~)โˆ’Es0โˆผฯ0[Vฯ€(s0)]

Since starting from s0โˆผฯ0, Using (value-function), also using (1.2.1), since t=0 we have :

(1.3.8)Vฯ€(s0)=โˆ‘l=0โˆžฮณlr(st)โ†’E[Vฯ€(s0)]=ฮท(ฯ€)

the expected return under policy is ฮทฯ€=E[Vฯ€(s0)], then (policy-relation) holds, so the proof completes.

(4) Visitation Frequencies โ€‹

We let the ฯฯ€ be the unnormalized discounted visitation frequencies.

(1.4.1)ฯฯ€(s)=P(s0=s)+ฮณP(s1=s)+ฮณ2P(s2=s)+โ€ฆ

This is the sum of the possibility to visit a specific state over some time. This is positive on every term. The ฯฯ€ is called visitation frequency density.

Using the relation (policy-relation), we can expand it using (1.1.5), we also limit the result state and action, i.e., st=s,at=a. on a deterministic states s and the available actions a, so the policy is written as ฯ€~(a|s), then we sum all the probability that under that policy, on all the possible states at time t.

Since the state on any s at all t under a trajectory, can be summed by t, then :

(1.4.2)Eฯ„โˆผฯ€~[โˆ‘t=0โˆžฮณtAฯ€(s,a)]=โˆ‘sโˆ‘t=0โˆžP(st=s|ฯ€~)โˆ‘aฯ€~(a|s)ฮณtAฯ€(s,a)

408

Title To help to understand above equations,
We note that A policy ฯ€~ is a rule or probability distribution for selecting actions, which is often a distribution of the next action :

ฯ€(a|s)={1ifย aย is chosen at some stateย s0ย otherwise

For example :

ฯ€~(a1|s)=0.7ฯ€~(a1|s)=0.3

then we substitute ฯ here, we got :

(1.4.3)ฮท(ฯ€~)=ฮท(ฯ€)+โˆ‘sฯฯ€~(s)โˆ‘aฯ€~(a|s)Aฯ€(s,a)

For any policy update ฯ€โ†’ฯ€~ if we ensure that :

(1.4.4)โˆ‘aฯ€~(a|s)Aฯ€(s,a)>0

then the performance of policy ฮท is ==guaranteed to increase==. But due to the estimation and approximation error.

(5) Local Approximation of performance โ€‹

The model training process is a process of optimizing the policy. From (1.4.3), we change the ฯ€~ in ฯ to the ฯ€, we get the approximation by substituting to visitation frequency ฯฯ€ :

(1.5.1)Lฯ€(ฯ€~)=ฮท(ฯ€)+โˆ‘sฯฯ€(s)โˆ‘aฯ€~(a|s)Aฯ€(s,a)

Subs the ฯ€ into above part, we have :

Lฯ€(ฯ€)=ฮท(ฯ€)

always satisfied

We note if, we have a policy that parametrized by ฮธ, i.e., ฯ€ฮธ(a|s), which is a differentiable function of the parameter vector ฮธ, then, Lฯ€ matches ฮท to first order. We have that for any parameter value set ฮธ0, we should make that :

(1.5.2)Lฯ€ฮธ0(ฯ€ฮธ)=ฮท(ฯ€ฮธ0)

satisfying :

(1.5.3)โˆ‡ฮธLฯ€ฮธ0(ฯ€ฮธ)|ฮธ=ฮธ0=โˆ‡ฮธฮทฯ€ฮธ|ฮธ=ฮธ0

We note that, for a sufficiently small step ฯ€ฮธ0โ†’ฯ€, we can use (1.5.2) to substitute ฮท in (1.4.3). So the new policy ฯ€new should be defined as following policy update criterion :

(1.5.4)ฯ€new(a|s)=(1โˆ’ฮฑ)ฯ€old(a|s)+ฮฑฯ€โ€ฒ(a|s)

In [3:1], the lowest bound is derived as :

(1.5.5)ฮท(ฯ€new)โ‰ฅฮทฯ€old(ฯ€new)โˆ’2ฯตฮณ(1โˆ’ฮณ)2ฮฑ2

where :

(1.5.6)ฯต=maxs|Eaโˆผฯ€โ€ฒ(a|s)[Aฯ€(s,a)]|

note (1.5.5) only applies to mixture policies generated by (1.5.4). This policy class is unwieldly and restrictive in practice.

2. Monotonic Improvement guarantee โ€‹

(1) Introduction โ€‹

For the lowest bound by (1.5.5), this is a principle applied into general stochastic policy classes (rather than just mixed classes of (1.5.4)). For all the possible policies, the (1.5.4) is often desired.

The Total Variation divergence is used for the distance measure, defined as half of Manhattan distance :

(2.1.1)DTV(p||q)=12โˆ‘i|piโˆ’qi|

We define we total variation distance DTV between two policies, is :

(2.1.2)DTVmax(ฯ€,ฯ€~)=maxsDTV(ฯ€(โ‹…|s)||ฯ€~(โ‹…|s))

In (1.5.4), we have :

Total variation distance theorem
The theorem is that, if we set ฮฑ=DTVmax(ฯ€old||ฯ€new), we have, the following relation holds :

(total-variation-distance){ฮท(ฯ€new)โ‰ฅLฯ€old(ฯ€new)โˆ’4ฯตฮณ(1โˆ’ฮณ)2ฮฑ2whereฯต=maxs,a|Aฯ€(s,a)|

(2) Using KL divergence to express โ€‹

In (total-variation-distance), the ฮฑ is held for the ฮฑ=DTVmax, we have the relation between the total variation divergence and the KL divergence [4], stated as :

(2.2.1)DTV(p||q)2โ‰คDKL(p||q)

Similar to (2.1.2), We still use a max notation to the KL divergence for policy difference (on all states) :

(2.2.2)DKLmax(ฯ€,ฯ€~)=maxsDKL(ฯ€(โ‹…|s)||ฯ€~(โ‹…|s))

We also have the relationship between the total variation divergence and the KL divergence, as :

(2.2.3)ฮท(ฯ€~)โ‰ฅLฯ€(ฯ€~)โˆ’4ฯตฮณ(1โˆ’ฮณ)2DKLmax(ฯ€,ฯ€~)

in later derivations, we set C=4ฯตฮณ(1โˆ’ฮณ)2

To maximize ฮท(ฯ€~) in the next iteration, we got the following optimization steps (here L is defined by (1.5.1)) :

(2.2.4)ฯ€i+1โ†argโกmaxฯ€[Lฯ€i(ฯ€)โˆ’CDKLmax(ฯ€i,ฯ€)โŸMi(ฯ€)]

Here M is a surrogate function that memorize ฮท. Thus we have :

(2.2.5)ฮท(ฯ€i+1)โˆ’ฮท(ฯ€i)โ‰ฅMi(ฯ€i+1)โˆ’Mi(ฯ€i)

The Trusted region policy optimization is an approximation of the algorithm (2.2.4). Such a policy uses constraint on the KL divergence rather than a penalty.

3. Trusted Region Policy Optimization โ€‹

(1) Parameterized Policy โ€‹

We considerate the optimization of the parameterized policy, i.e., ฯ€ฮธ(a|s) with the parameter vector ฮธ, so that, we can express the notations on the policy by ฮธ, e.g. (1.5.1) and (2.2.3) as :

(3.1.1)L(ฮธ):=Lฯ€ฮธ(ฯ€ฮธ)ฮท(ฮธ):=ฮท(ฯ€ฮธ)

The target is to maximize M(ฮธ), i.e., :

(3.1.2)maximizeฮธ[Lฮธold(ฮธ)โˆ’CDKLmax(ฮธold,ฮธ)]

Trusted region policy constraint
In the practical case, since DKL is always positive, we can make the second term as small as possible, then, the trust region constraint is constructed as :

(trusted-region-policy){maximizeฮธLฮธold(ฮธ)subject toDKLmax(ฮธold,ฮธ)โ‰คฮด

Here ฮธ(a|s) depends on the available actions states.

We note the problem in Theorem. TRPO is a problem solved in the KL divergence bounded space, but such a problem is intractable, (this is because, the max is applied in the firstly equation, so for every state, it impose a new constraint, and in the reinforced learning, there is often a great number of states, and the policy ฮธ=ฮธ(โ‹…|s1,2,โ€ฆ) ) depends on the states.

So the second constraint is applied by an average on the states :

(3.1.3)Dโ€•KLฯ(ฮธ1,ฮธ2):=Esโˆผฯ[DKL(ฯ€ฮธ1(โ‹…|s)||ฯ€ฮธ2(โ‹…|s))]

So (trusted-region-policy) becomes following :

(3.1.4){maximizeฮธLฮธold(ฮธ)subject toDโ€•KLฯฮธold(ฮธold,ฮธ)โ‰คฮด

Here ฯ is a state distribution used to average the state-wise KL divergence (the states are sampled according to the ฯ, defined in (1.4.1)).

Usually, the ฯ in above equation is chosen as the state visitation distribution under the old policy.

ฯ=ฯฮธold

i.e., according to the definition,

(sampling-distribution)ฯฯ€(s)=โˆ‘t=0โˆžฮณtP(st=s|ฯ€)

Sometimes, the ฯฯ€ is also normalized as following :

(3.1.5)dฯ€(s)=(1โˆ’ฮณ)โˆ‘t=0โˆžฮณtP(st=s|ฯ€)

4. Sample-based estimation โ€‹

(1) Problem construction โ€‹

Since the L is the approximated performance defined in (1.5.1), the optimization problem (3.1.4) is written as :

(4.1.1)maximizeโˆ‘sฯฮธold(s)โˆ‘aฯ€ฮธAฯ€(s,a)subject toDโ€•KLฯฮธold(ฮธold,ฮธ)โ‰คฮด

we note under a sampling distribution q, the contribution of a single sn can be expressed by the importance sampling estimator[5]. That is, we use distribution aโˆผq and importance sampling to compute the average :

(4.1.2)โˆ‘aฯ€ฮธ(a|sn)Aฮธold(sn,a)=Eaโˆผq(โ‹…โˆฃsn)[ฯ€ฮธ(a|sn)q(a|sn)Aฮธold(sn,a)]

then the problem (3.1.4) will become :

(4.1.3)maximizeEsโˆผฯฮธold,aโˆผq[ฯ€ฮธ(a|sn)q(a|sn)Qฮธold(sn,a)]subject toEsโˆผฯฮธold[DKL(ฯ€ฮธold||ฯ€ฮธ)]โ‰คฮด

We note in the (4.1.3), the change from A to Q is valid only as an optimization-equivalence. Considering the (advantage-function),

(4.1.4)Eaโˆผฯ€ฮธ[Aฮธold(s,a)]=Eaโˆผฯ€ฮธ[Qฮธold(s,a)โˆ’Vฮธold(s)โŸnot depend onย ฮธ]

in the optimization process, since we want to maximize, the second term in (4.1.4) is a constant and thus can be dropped.

We also note the sโˆผฯฮธold and aโˆผq is the single path sample-based estimation for the objective and constraint.

Another estimation is the Vine method, in which we will choose a subset of N states along these trajectories. We can sample K actions rather than using an,kโˆผq(โ‹…|sn).

In the vine estimation, we can choose any q(โ‹…|sn) with a support that includes the support of ฯ€ฮธ(โ‹…|sn) will produce a consistent estimator. Using use q(โ‹…|sn)=ฯ€ฮธi(โ‹…|sn) still works well. This method finally yield following equations. But we will not cover them in detail :

Ln(ฮธ)=โˆ‘k=1Kฯ€ฮธ(ak|sn)Q^(sn,ak)

using the importance sampling like 4.1.2, we also can get :

Ln(ฮธ)=โˆ‘k=1Kฯ€ฮธ(an,k|sn)ฯ€ฮธold(an,k|sn)Q^(sn,an,k)โˆ‘k=1Kฯ€ฮธ(an,k|sn)ฯ€ฮธold

References โ€‹


  1. Schulman, John, Sergey Levine, Philipp Moritz, Michael I. Jordan, and Pieter Abbeel. โ€œTrust Region Policy Optimization.โ€ arXiv:1502.05477. Preprint, arXiv, April 20, 2017. https://doi.org/10.48550/arXiv.1502.05477 โ†ฉ๏ธŽ

  2. 1. Markov-decision-process โ†ฉ๏ธŽ โ†ฉ๏ธŽ โ†ฉ๏ธŽ โ†ฉ๏ธŽ โ†ฉ๏ธŽ

  3. Kakade, Sham and Langford, John. Approximately optimal approximate reinforcement learning. In ICML, volume 2, pp. 267โ€“274, 2002. https://people.eecs.berkeley.edu/~pabbeel/cs287-fa09/readings/KakadeLangford-icml2002.pdf โ†ฉ๏ธŽ โ†ฉ๏ธŽ

  4. 2. Kullback-Leibler divergence โ†ฉ๏ธŽ

  5. 2. Monte-Carlo Sampling and Importance Sampling โ†ฉ๏ธŽ